#ifndef ALBUMTOPWIDGET_H
#define ALBUMTOPWIDGET_H

#include <QDate>
#include <QPen>
#include <QStyle>
#include <QWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPropertyAnimation>
#include <QResizeEvent>
#include <QFocusEvent>
#include <QPaintEvent>

#include <songitem.h>
#include <popuplistwidget.h>

class TelescopicLineEdit;

class AlbumTopWidget : public QWidget
{
    Q_OBJECT
public:
    explicit AlbumTopWidget(QWidget *parent = nullptr);
    void SetAlbumPicture(const QString&filepath);
    void SetAlbumPicture(const QByteArray&data);
    void SetAlbumPicture(const QPixmap&picture);
    void SetAlbumPicture(const QImage&picture);
    void SetAlbumInfo(qint32 playnum,const QString&albumtitle,const QString&intro);
    void SetAlbum(const QString&filepath,qint32 playnum,const QString&albumtitle,const QString&intro){SetAlbumPicture(filepath);SetAlbumInfo(playnum,albumtitle,intro);}//分别是专辑图片，播放数，标题，简介
    void SetAlbum(const QByteArray&data,qint32 playnum,const QString&albumtitle,const QString&intro){SetAlbumPicture(data);SetAlbumInfo(playnum,albumtitle,intro);}//分别是专辑图片，播放数，标题，简介
    void SetCreator(const QString&filepath,const QString&name,const QStringList&tags,const QDate& date);
    void SetCreator(const QByteArray&data,const QString&name,const QStringList&tags,const QDate& date);
    void SetSmallPrintSongNum(qint32 songsnum){albumsonglabel->setText(songsnum);}
    void BulkOperationsMode();

signals:
    void playall();
    void favor();
    void download();
    void more(const QPoint&point);
    void showSongItem();
    void showComment();
    void showFavor();
    void textEdited(const QString&text);
protected:
    void resizeEvent(QResizeEvent*e)override;
private slots:
    void onClickAlbumBottomLabel();
    void onClickIntroDetailLabel();
private:
    void SetFont();

    QLabel*albumpicturelabel,*albumtitlelabel,*taglabel,*createdatelabel;
    QPushButton*albumplaynumlabel;
    AdaptiveMultiLabel*multitagslabel;
    QLineEdit*introline;
    TelescopicLineEdit*searchline;
    ClickedLabel*creatorheadshotlabel,*creatornamelabel,*introdetaillabel;
    QPushButton*setplayallbtn,*setfavorbtn,*setdownloadbtn,*setmorebtn;
    SmallPrintLabel*albumsonglabel,*albumcommentlabel,*albumcollectorlabel;
    PopupTextEdit*introtextedit;
    QHBoxLayout*creatorlayout,*setlayout,*albuminfolayout,*introlayout,*hmain;
    QVBoxLayout*vmain,*rightlayout,*leftlayout;

    QString introduction;//记录简介
};

class TelescopicLineEdit:public QLineEdit
{
    Q_OBJECT
    Q_PROPERTY(int width READ width WRITE setWidth )
public:
    TelescopicLineEdit(QWidget*parent=nullptr);
    void SetExpandWidth(const int width);
    void SetShrinkWidth(const int width);
protected:
    void focusInEvent(QFocusEvent*e)override;
    void focusOutEvent(QFocusEvent*e)override;
private:
    int width(){return QLineEdit::width();}
    void setWidth(int newwidth){QLineEdit::setFixedWidth(newwidth);}
    QPropertyAnimation* expandanimation;
    QPropertyAnimation* shrinkanimation;
    int expandwidth;
    int shrinkwidth;
};

// class MarkedButton:public QPushButton
// {
//     Q_OBJECT
// protected:
//     void paintEvent(QPaintEvent*e)override;
// };

#endif // ALBUMTOPWIDGET_H
